﻿<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             x:Class="GiveAQuiz.QuizManager.Views.EditorView"
             mc:Ignorable="d"
             d:DesignWidth="159"
             d:DesignHeight="282">
  <Grid x:Name="LayoutRoot">
    <Grid.RowDefinitions>
      <RowDefinition />
      <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>
    <ScrollViewer Margin="8"
                  VerticalScrollBarVisibility="Auto"
                  HorizontalScrollBarVisibility="Hidden"
                  BorderBrush="Transparent"
                  Background="Transparent"
                  x:Name="theScroller">
      <ItemsControl ItemsSource="{Binding Questions}"
                    HorizontalContentAlignment="Stretch"
                    VerticalContentAlignment="Stretch"
                    x:Name="theList">
        <ItemsControl.ItemTemplate>
          <DataTemplate>
            <Grid Width="540"
                  HorizontalAlignment="Stretch"
                  Margin="8"
                  DataContext="{Binding}"
                  VerticalAlignment="Stretch">
              <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition />
                <ColumnDefinition Width="Auto" />
              </Grid.ColumnDefinitions>
              <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition />
              </Grid.RowDefinitions>
              <StackPanel Orientation="Horizontal"
                          Margin="0 0 2 0">
                <TextBlock Text="{Binding Definition.SortOrder}" />
                <TextBlock><Run Text="." /></TextBlock>
              </StackPanel>
              <StackPanel Grid.Column="2"
                          Grid.RowSpan="2"
                          Margin="2">
                <Button Style="{StaticResource ImageButton}"
                        Margin="1"
                        Command="{Binding DataContext.MoveUpQuestionCommand, ElementName=theList}"
                        CommandParameter="{Binding}">
                  <Image Source="/GiveAQuiz.Common;component/images/prev.png" />
                </Button>
                <Button Style="{StaticResource ImageButton}"
                        Margin="1"
                        Command="{Binding DataContext.MoveDownQuestionCommand, ElementName=theList}"
                        CommandParameter="{Binding}" ToolTipService.ToolTip="Move Question Down">
                  <Image Source="/GiveAQuiz.Common;component/images/next.png" />
                </Button>
                <Button Style="{StaticResource ImageButton}"
                        Margin="1"
                        Command="{Binding DataContext.DeleteQuestionCommand, ElementName=theList}"
                        CommandParameter="{Binding}" ToolTipService.ToolTip="Delete Question">
                  <Image Source="/GiveAQuiz.Common;component/images/del.png" />
                </Button>
              </StackPanel>
              <TextBlock Grid.Column="1"
                         Text="{Binding DisplayName}" />
              <ContentPresenter Grid.Column="1"
                                Grid.Row="1"
                                Content="{Binding}"
                                ContentTemplate="{Binding EditorTemplate}"
                                HorizontalAlignment="Stretch" />
            </Grid>
          </DataTemplate>
        </ItemsControl.ItemTemplate>
      </ItemsControl>
    </ScrollViewer>
  </Grid>
</UserControl>
